#!/usr/bin/ruby
# -*- ruby -*-
#
# http://programmingpraxis.com/2014/02/18/two-interview-questions/

require 'pp'
require 'set'

def diff(arr1, arr2)
  s1 = Set.new(arr1)
  s2 = Set.new(arr2)

  return s2 - s1
end

n = ! ARGV.empty? ? ARGV.first.to_i : 10

arr1 = Array.new(n) { rand(256) }

arr2 = arr1.clone
arr2 << rand(256)
arr2 << rand(256)
arr2.shuffle!

d = diff(arr1, arr2)

puts arr1.sort.inspect
puts arr2.sort.inspect
puts d.to_a.sort.inspect
